<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
	<script type="text/javascript">
	function reloadImage(t){
		t.src="servlet/CheckCodet";
	}
	function checkstr(str){
		var n=0;
			for(i=0;i<str.length;i++){
				var leg=str.charCodeAt(i);
				if(leg>255){
					n+=2;
				}else{
					n+=1;
				}
			}
			if(n>10){
				return true;
			}else{
				return false;
			}
			
	}
	function chkinput(form){
		if(form.username.value==""){
			alert("请输入用户名");
			form.username.focus();
			return false;
		}
		if(checkstr(form.username.value)){
			alert("您输入的用户名过长，请重新输入！");
			form.username.focus();
			return false;
		}
		if(form.userpwd.value==""){
			alert("请输入用户密码！");
			form.userpwd.focus();
			return false;
		}
		if((form.userpwd.value.length)<=4){
			alert("您输入的密码过短，请重新输入！ ");
			form.userpwd.focus();
			return false;
		}
		
		return true;
	}
	</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录界面</title>
</head>
<body>
	<form action="servlet/LoginServlet" method="post" name="loginform">
	<h3>用户登陆</h3>
		<table>
			<tr>
				<td>用户名：</td>
				<td><input type="text" name="username" placeholder="请输入用户名"></td>
			</tr>
			<tr>
				<td>密码：</td>
				<td><input type="password" name="pwd" placeholder="请输入密码"></td>
			</tr>
			<tr>
				<td width="50px">验证码</td>
				<td > <input type="text" name="checkcode"  placeholder="请输入验证码"><img alt="看不清，点击这里" src="servlet/CheckCode" onClick="reloadImage(this)">
				    </td>
			</tr>
			<tr>
				<td><input type="reset" value="重置"> </td>
				<td><input type="submit" value="登录" onClick="chkinput(loginform)"></td>
			</tr>
		
		</table>
	</form>

</body>
</html>